﻿using System;

namespace YArchitech.Plumbing
{
	public class HotUsedWaterCal
	{
		public HotUsedWaterCal(WaterCalculateType type, string name)
		{
			this.calculateType = type;
			this.typeName = name;
			this.maxUsedProposal = 0.0;
			this.maxUsedRange = "";
			this.unit = "";
			this.usedTimeRange = "";
			this.usedTimeProposal = 0.0;
			this.usedCount = 1.0;
			this.coefficientProposal = 100.0;
			this.oneUsedRange = "";
			this.usedTempRange = "";
			this.usedTempProposal = 0.0;
			this.usedCount = 1.0;
			this.heatPerHour = 0.0;
		}

		public HotUsedWaterCal(HotUsedWaterCal obj)
		{
			this.calculateType = obj.calculateType;
			this.typeName = obj.typeName;
			this.maxUsedProposal = obj.maxUsedProposal;
			this.maxUsedRange = obj.maxUsedRange;
			this.usedCount = obj.usedCount;
			this.unit = obj.unit;
			this.usedTimeRange = obj.usedTimeRange;
			this.usedTimeProposal = obj.usedTimeProposal;
			this.coefficientProposal = obj.coefficientProposal;
			this.oneUsedRange = obj.oneUsedRange;
			this.usedTempRange = obj.usedTempRange;
			this.usedTempProposal = obj.usedTempProposal;
			this.heatPerHour = obj.heatPerHour;
		}

		public virtual WaterCalculateType calculateType { get; set; }

		public virtual string typeName { get; set; }

		public virtual double maxUsedProposal { get; set; }

		public virtual string maxUsedRange { get; set; }

		public virtual string unit { get; set; }

		public virtual string usedTimeRange { get; set; }

		public virtual double usedTimeProposal { get; set; }

		public virtual double usedCount { get; set; }

		public virtual string oneUsedRange { get; set; }

		public virtual string usedTempRange { get; set; }

		public virtual double usedTempProposal { get; set; }

		public virtual double coefficientProposal { get; set; }

		public virtual double heatPerHour { get; set; }

		public virtual bool Calculate()
		{
			bool result = false;
			double num = 4.187;
			double num2 = 0.9832;
			double num3 = HotUsedWaterCalManage.Instance.HotTemp - HotUsedWaterCalManage.Instance.ColdTemp;
			try
			{
				if (HotUsedWaterCalManage.Instance.bIsCalForDay)
				{
					if (this.usedTimeProposal != 0.0)
					{
						this.heatPerHour = this.coefficientProposal * this.usedCount * this.maxUsedProposal * num * num3 * num2 / this.usedTimeProposal;
						result = true;
					}
				}
				else
				{
					num3 = this.usedTempProposal - HotUsedWaterCalManage.Instance.ColdTemp;
					this.heatPerHour = this.maxUsedProposal * num3 * num2 * this.usedCount * (this.coefficientProposal / 100.0) * num;
					result = true;
				}
			}
			catch (Exception ex)
			{
				ex.ToString();
			}
			return result;
		}
	}
}
